﻿using System;
using System.Collections.Generic;
using System.Web.Mvc.Html;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.Fields;

namespace WebSite.ViewModels.IndexViewModels
{
    public static class VendedorIndexColumns
    {
        public static Guid Nome = new Guid("d6dd3f75-4c10-41c2-a40d-0289ace37bd4");
        public static Guid NumeroClientes = new Guid("cbe2cc94-3540-402d-bd1c-e32fd2e66849");
        public static Guid Nascimento = new Guid("1be2cc94-3540-402d-bd1c-e32fd2e66849");
        public static Guid CPF = new Guid("2be2cc94-3540-402d-bd1c-e32fd2e66849");
        public static Guid Identidade = new Guid("3be2cc94-3540-402d-bd1c-e32fd2e66849");
    }

    public class VendedorIndexViewModel : UsuariosHolderIndexViewModel<Vendedor>
    {
        public VendedorIndexViewModel(bool canCreatePedido)
            : base("Vendedores", canCreatePedido)
        {
        }

        public string NomeBuscaValue { get; set; }

        protected override void RegisterColumns(IndexColumnDefinitionsCollectionWrapper<Vendedor> indexColumnDefinitionsCollectionWrapper)
        {
            indexColumnDefinitionsCollectionWrapper.Register(VendedorIndexColumns.Nome, (vendedor, htmlHelper) => htmlHelper.ActionLink(vendedor.Nome, "Details", new { id = vendedor.Id }));
            indexColumnDefinitionsCollectionWrapper.Register(VendedorIndexColumns.NumeroClientes, x => x.NumeroDeClientes);
            indexColumnDefinitionsCollectionWrapper.Register(VendedorIndexColumns.Nascimento, x => x.Nascimento);
            indexColumnDefinitionsCollectionWrapper.Register(VendedorIndexColumns.CPF, x => x.CPF);
            indexColumnDefinitionsCollectionWrapper.Register(VendedorIndexColumns.Identidade, x => x.Identidade);
            base.RegisterColumns(indexColumnDefinitionsCollectionWrapper);
        }

        protected override IEnumerable<IField> GetSearchFields()
        {
            List<IField> result = new List<IField>
            {
                new TextBoxField("Nome", "nome", NomeBuscaValue)
            };
            result.AddRange(base.GetSearchFields());
            return result;
        }
    }
}